//
//  LXPrepareGetGoodsOrderViewCell.m
//  LvXi_newVersion
//
//  Created by 诸葛孔明 on 16/8/12.
//  Copyright © 2016年 SJT. All rights reserved.
//............................................................................................//
//...........................................待收货订单cell...........................................//
//............................................................................................//

#import "LXPrepareGetGoodsOrderViewCell.h"

@interface LXPrepareGetGoodsOrderViewCell ()

/**描述*/
@property(nonatomic,weak)UILabel *totalLabel;
/**一个字----共*/
@property(nonatomic,weak)UILabel *oneWord;
/**实付*/
@property(nonatomic,weak)UILabel *moneyLabel;

@end

@implementation LXPrepareGetGoodsOrderViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {

        //图片
        UIImageView *goodsImage = [[UIImageView alloc] init];
        [self addSubview:goodsImage];
        self.goodsImage = goodsImage;
        
        //商品名称
        UILabel *nameLabel = [[UILabel alloc] init];
        nameLabel.font = [UIFont systemFontOfSize:12];
        nameLabel.textAlignment = NSTextAlignmentLeft;
        nameLabel.textColor = HexColor(@"#222222");
        nameLabel.numberOfLines = 3;
        [self addSubview:nameLabel];
        self.nameLabel = nameLabel;
        
        //商品价格
        UILabel *priceLabel = [[UILabel alloc] init];
        priceLabel.font = [UIFont systemFontOfSize:12];
        priceLabel.textAlignment = NSTextAlignmentLeft;
        [self addSubview:priceLabel];
        self.priceLabel = priceLabel;
        
        //店家名称
        UILabel *shopNameLabel = [[UILabel alloc] init];
        shopNameLabel.font = [UIFont systemFontOfSize:10];
        shopNameLabel.textAlignment = NSTextAlignmentCenter;
        shopNameLabel.textColor = HexColor(@"#999999");
        [self addSubview:shopNameLabel];
        self.shopNameLabel = shopNameLabel;
        
        //购买数量
        UILabel *countLabel = [[UILabel alloc] init];
        countLabel.font = [UIFont systemFontOfSize:12];
        countLabel.textAlignment = NSTextAlignmentCenter;
        countLabel.textColor = [UIColor orangeColor];
        [self addSubview:countLabel];
        self.countLabel = countLabel;
        
        //商品规格
        UILabel *introduceLabel = [[UILabel alloc] init];
        introduceLabel.font = [UIFont systemFontOfSize:10];
        introduceLabel.textAlignment = NSTextAlignmentCenter;
        introduceLabel.textColor = HexColor(@"#999999");
        [self addSubview:introduceLabel];
        self.introduceLabel = introduceLabel;
        
        //文字:件商品
        UILabel *totalLabel = [[UILabel alloc] init];
        totalLabel.font = [UIFont systemFontOfSize:12];
        totalLabel.textAlignment = NSTextAlignmentCenter;
        totalLabel.text = @" 件商品";
//        [self addSubview:totalLabel];
        self.totalLabel = totalLabel;
        
        //商品购买件数
        UILabel *shop_countLabel = [[UILabel alloc] init];
        shop_countLabel.font = [UIFont systemFontOfSize:12];
        shop_countLabel.textAlignment = NSTextAlignmentCenter;
        shop_countLabel.textColor = [UIColor redColor];
        [self addSubview:shop_countLabel];
        self.shop_countLabel = shop_countLabel;
        
        //文字:共
        UILabel *oneWord = [[UILabel alloc] init];
        oneWord.font = [UIFont systemFontOfSize:12];
        oneWord.textAlignment = NSTextAlignmentCenter;
        oneWord.text = @"共";
//        [self addSubview:oneWord];
        self.oneWord = oneWord;
        
        //文字:实付
        UILabel *moneyLabel = [[UILabel alloc] init];
        moneyLabel.font = [UIFont systemFontOfSize:12];
        moneyLabel.textAlignment = NSTextAlignmentCenter;
        moneyLabel.text = @"实付";
//        [self addSubview:moneyLabel];
        self.moneyLabel = moneyLabel;
        
        //付款钱数
        UILabel *payLabel = [[UILabel alloc] init];
        payLabel.font = [UIFont systemFontOfSize:12];
        payLabel.textAlignment = NSTextAlignmentCenter;
        payLabel.textColor = [UIColor orangeColor];
//        [self addSubview:payLabel];
        self.payLabel = payLabel;
     
        //查看物流按钮
        UIButton *checkLogisticsButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [checkLogisticsButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
        checkLogisticsButton.layer.cornerRadius = 5;
        checkLogisticsButton.layer.borderColor = [UIColor orangeColor].CGColor;
        checkLogisticsButton.layer.borderWidth = 1;
        [checkLogisticsButton setTitle:@"查看物流" forState:UIControlStateNormal];
//        [checkLogisticsButton setBackgroundImage:<#(nullable UIImage *)#> forState:<#(UIControlState)#>]

//        [checkLogisticsButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
        checkLogisticsButton.layer.cornerRadius = 5;
        [checkLogisticsButton setTitle:@"查看物流" forState:UIControlStateHighlighted];
        
        checkLogisticsButton.titleLabel.font = [UIFont systemFontOfSize:14];
        [checkLogisticsButton addTarget:self action:@selector(checkLogisticsButtonClick) forControlEvents:UIControlEventTouchUpInside];
//        [self addSubview:checkLogisticsButton];
        self.checkLogisticsButton = checkLogisticsButton;
        
        [self setBackgroundImageViewHeight:MineRatio(130)];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    //商品图片
    self.goodsImage.x = 20;
    self.goodsImage.y = 15;
    self.goodsImage.width = MineRatio(100);
    self.goodsImage.height = MineRatio(100);
    
    
    //商品价格
    self.priceLabel.width = [self.priceLabel.text sizeInAre:MaxSize font:self.priceLabel.font].width;
    self.priceLabel.height = [self.priceLabel.text sizeInAre:MaxSize font:self.priceLabel.font].height;
    
    self.priceLabel.x = self.width - self.priceLabel.width - 15;
    
    //商品名称
    self.nameLabel.size = [self.nameLabel.text sizeInAre:CGSizeMake(ScreenWidth-self.goodsImage.right-3*globalMargin-self.priceLabel.width, MAXFLOAT) font:self.nameLabel.font];
    self.nameLabel.x = self.goodsImage.right + 10;
    self.nameLabel.y = self.goodsImage.y;
    
    self.priceLabel.y = self.nameLabel.y;
    
    //商品规格
    self.introduceLabel.width = [self.introduceLabel.text sizeInAre:MaxSize font:self.introduceLabel.font].width;
    self.introduceLabel.height = [self.introduceLabel.text sizeInAre:MaxSize font:self.introduceLabel.font].height;
    self.introduceLabel.y = self.goodsImage.botton - self.introduceLabel.height;
    self.introduceLabel.x = self.nameLabel.x;
    
    //店家名称
    self.shopNameLabel.width = [self.shopNameLabel.text sizeInAre:MaxSize font:self.shopNameLabel.font].width;
    self.shopNameLabel.height = [self.shopNameLabel.text sizeInAre:MaxSize font:self.shopNameLabel.font].height;
    self.shopNameLabel.y = self.introduceLabel.top - self.shopNameLabel.height - 10;
    self.shopNameLabel.x = self.nameLabel.x;
    
    //购买数量
    self.countLabel.width = [self.countLabel.text sizeInAre:MaxSize font:self.countLabel.font].width;
    self.countLabel.height = [self.countLabel.text sizeInAre:MaxSize font:self.countLabel.font].height;
    self.countLabel.y = self.shopNameLabel.y;
    self.countLabel.x = self.width - self.countLabel.width - 15;
    
    //付款钱数
    self.payLabel.width = [self.payLabel.text sizeInAre:MaxSize font:self.payLabel.font].width;
    self.payLabel.height = [self.payLabel.text sizeInAre:MaxSize font:self.payLabel.font].height;
    self.payLabel.y = self.introduceLabel.botton + 18;
    self.payLabel.x = self.width - self.payLabel.width - 15;
    
    //文字:实付
    self.moneyLabel.width = [self.moneyLabel.text sizeInAre:MaxSize font:self.moneyLabel.font].width;
    self.moneyLabel.height = [self.moneyLabel.text sizeInAre:MaxSize font:self.moneyLabel.font].height;
    self.moneyLabel.y = self.payLabel.y;
    self.moneyLabel.x = self.payLabel.x - self.moneyLabel.width;
    
    //文字:件商品
    self.totalLabel.width = [self.totalLabel.text sizeInAre:MaxSize font:self.totalLabel.font].width;
    self.totalLabel.height = [self.totalLabel.text sizeInAre:MaxSize font:self.totalLabel.font].height;
    self.totalLabel.y = self.payLabel.y;
    self.totalLabel.x = self.moneyLabel.x - self.totalLabel.width - 5;
    
    //购买商品件数
    self.shop_countLabel.width = [self.shop_countLabel.text sizeInAre:MaxSize font:self.shop_countLabel.font].width;
    self.shop_countLabel.height = [self.shop_countLabel.text sizeInAre:MaxSize font:self.shop_countLabel.font].height;
    self.shop_countLabel.y = self.payLabel.y;
    self.shop_countLabel.x = self.totalLabel.x - self.shop_countLabel.width;
    
    //文字:共
    self.oneWord.width = [self.oneWord.text sizeInAre:MaxSize font:self.oneWord.font].width;
    self.oneWord.height = [self.oneWord.text sizeInAre:MaxSize font:self.oneWord.font].height;
    self.oneWord.y = self.payLabel.y;
    self.oneWord.x = self.shop_countLabel.x - self.oneWord.width;
    
    //查看物流按钮
    self.checkLogisticsButton.width = MineRatio(83);
    self.checkLogisticsButton.height = self.height - self.shop_countLabel.botton - 20;
    self.checkLogisticsButton.x = self.width - self.checkLogisticsButton.width - 15;
    self.checkLogisticsButton.centerY = self.oneWord.botton + 10 + self.checkLogisticsButton.height * 0.5;
    
}

#pragma mark - 查看物流按钮点击
- (void)checkLogisticsButtonClick
{
    NSLog(@"%s",__func__);
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
//    [super setSelected:selected animated:animated];
}

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
    
}

@end
